<?php

namespace App\Console\Commands;

use App\Modules\DataCenter\Controllers\BarberStatisticsController;
use App\Modules\DataCenter\Controllers\StatisticsController;
use App\Modules\Order\Controllers\OrderController;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Log;

class withdraw extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'withdraw';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'this is as withdraw crontab test ';
	private $store;
	private $order;
	private $barberStatisticsController;
    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct(StatisticsController $statisticsController,OrderController $orderController,BarberStatisticsController $barberStatisticsController)
    {
        parent::__construct();
	    $this->store = $statisticsController;
	    $this->order = $orderController;
	    $this->barberStatisticsController = $barberStatisticsController;
    }

	/**
	 * 定时任务
	 * @throws \App\Exceptions\NotFoundException
	 */
    public function handle()
    {
	    Log::info('任务调度开始'.date('Y-m-d H:i:s',time()));
	    Log::info('店铺排名任务开始'.date('Y-m-d H:i:s',time()));
        $result = $this->store->rankStore();
	    Log::info($result);
	    Log::info('店铺排名任务结束'.date('Y-m-d H:i:s',time()));
	    Log::info('订单过期任务开始'.date('Y-m-d H:i:s',time()));
	    $expiredOrderList = $this->order->expiredOrderList();
	    Log::info($expiredOrderList);
	    Log::info('订单过期任务结束'.date('Y-m-d H:i:s',time()));
	    Log::info('理发师工资任务开始'.date('Y-m-d H:i:s',time()));
	    $barberSalary = $this->barberStatisticsController->barberSalaryAdd();
	    Log::info($barberSalary);
	    Log::info('理发师工资任结束'.date('Y-m-d H:i:s',time()));
	    Log::info('任务调度结束'.date('Y-m-d H:i:s',time()));

    }
}
